package com.majun.base.flux;

import java.util.Arrays;

import reactor.core.publisher.Flux;

public class FluxExample {

	public static void main(String[] args) {
		// 从静态数据创建
		Flux<String> flux1 = Flux.just("Hello", "World");

		// 从集合创建
		Flux<Integer> flux2 = Flux.fromIterable(Arrays.asList(1, 2, 3, 4, 5));

		// 生成动态数据
		Flux<Integer> flux3 = Flux.range(1, 10);

		// 创建无限流
//		Flux<Long> flux4 = Flux.interval(Duration.ofSeconds(1));

		// 订阅Flux
		flux1.subscribe(System.out::println);
		flux2.subscribe(System.out::println);
		flux3.subscribe(System.out::println);
//		flux4.subscribe(System.out::println);
	}
}
